import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

/**
 * @Description TODO
 * @Author hhy
 * @Date 2020/10/19 14:24
 */
public class FileUtils {

    public void copyFile(InputStream in, OutputStream out){
        byte[] bytes = new byte[1024];
        int n = 0;

        try {
            while ((n = in.read(bytes))!=-1){
                out.write(bytes,0,n);
                //out.flush(); 一般情况下，不需要使用这个方法，因为写满了这个会自动调用
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void serializableObj(Object o, ObjectOutputStream out){
        try {
            out.writeObject(o);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
